package controller;

import management.ApplicationManager;
import view.ConfigurationView;
import view.GenericView;
import view.ResultadosView;
import view.StartView;
import view.VotacionView;

public class StartController implements GenericController{
	
	private ConfigurationController configController;
	private VotacionController votacController;
	private ResultadosController resultadosController;
	private ApplicationManager manager;
	
	public StartController() {
		this.configController = new ConfigurationController(this);
		this.votacController = new VotacionController(this);
		this.resultadosController = new ResultadosController(this);
	}

	public void handleButtonVotar() {
		((VotacionView)this.votacController.getView()).setController(this.votacController);
		((VotacionView)this.votacController.getView()).setList();	
		this.votacController.getView().showWindow();
		this.getView().hideWindow();
	}

	public void handleButtonResultados() {
		((ResultadosView)this.resultadosController.getView()).setController(this.resultadosController);
		((ResultadosView)this.resultadosController.getView()).setList();	
		this.resultadosController.getView().showWindow();
		this.getView().hideWindow();
	}

	public void handleButtonConfiguracin() {
		((ConfigurationView)this.configController.getView()).setController(this.configController);
		this.configController.notityChangeInCandidatesList();
		this.configController.getView().showWindow();
		this.getView().hideWindow();
	}

	public void handleButtonSalir() {
		System.exit(0);
	}
	
	public GenericView getView(){
		return StartView.getInstance();
	}

	@Override
	public GenericController getParentController() {
		return null;
	}

	public ApplicationManager getManager() {
		return manager;
	}

	public void setManager(ApplicationManager manager) {
		this.manager = manager;
	}

	public void cargarDatos() {
		this.setManager(new ApplicationManager());
		this.getManager().cargar();
	}

}
